//  对外暴露插件对象

import { App } from 'vue'
// 引入全局组件
import SvgIcon from '@/components/SvgIcon/index.vue'
import Pagination from '@/components/Pagination/index.vue'
import Category from '@/components/Category/index.vue'
// 引入element-plus 提供全部图标组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'


// 全局对象
const allGlobalComponent = {
  SvgIcon,
  Pagination,
  Category
}
export default {
  install(app: App) {
    Object.keys(allGlobalComponent).forEach(key => {
      // 注册全局组件
      app.component(key, allGlobalComponent[key as keyof typeof allGlobalComponent])
      // 注册element-plus图标组件
      for (const [iconName, component] of Object.entries(ElementPlusIconsVue)) {
        app.component(iconName, component)
      }
    })
  }
}